<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" session="false" %>
<%@ page import="hiclib.CAuthenticate, hiclib.hicdata.CUser" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
	HttpSession ss;
	String company = request.getParameter("company");
	String id = request.getParameter("id");
	String password = request.getParameter("password");
	
	String url = null; 
	CUser user = null;
	if (company.isEmpty()||id.isEmpty()||password.isEmpty()) {
		url = "Login.jsp";
	}	else {
		CAuthenticate auth = new CAuthenticate();
		
		if (auth.UserCheck(company,id,password)){ 
			ss = request.getSession(true);
			user = auth.getUser();
			ss.setAttribute("user", user);
			url = "main.jsp";
		} else {
			url = "Login.jsp";			
		}
		auth.finalize();
	}
	
	response.sendRedirect(url);
%>

</body>
</html>